package day06;
import java.util.Scanner;
public class Test01 {
    public static void main(String[] args) {
        //1.录入数据：
        double []sco= enterScore();
        //2.计算总分：
        double sum1 = TotalScore(sco);
        System.out.println("总分："+sum1);
        //3.计算平均分
        double avg =calAvg(sco);
        System.out.println("最终平均分为："+avg);
        }

//1.录入成绩
    public static double[]enterScore (){
        Scanner scan = new Scanner(System.in);
        double[]score=new double[6];
        for (int i=0;i< score.length;i++){
            System.out.println("请录入第"+(i+1)+"评委的分数");
            score[i]= scan.nextDouble();
        }
        return score;
    }
//2.计算总分
    public static double TotalScore(double[]arr) {
        double sum = 0;
        for (int i = 0; i < arr.length; i++) {
            sum += arr[i];
        }
        double max = arr[0];
        double min = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if (arr[i] > max) {
                max = arr[i];
            }
            if (arr[i] < min) {
                min = arr[i];
            }
        }
            double total = sum - max - min;
            return total;
        }

    public static double calAvg(double[]arr){
        double total =TotalScore(arr);
        double avg = total/(arr.length-2);
        return  avg;
    }
    }



